﻿using UnityEngine;
using UnityEditor;

namespace SocketWeaver.FixedMath.CustomUnityEditor
{
    [CustomEditor(typeof(FTransformTest))]
    //[CanEditMultipleObjects]
    public class FTransformTestCustomInspector : Editor
    {


        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            FTransformTest test = (FTransformTest)target;
            FTransform ft = test.GetComponent<FTransform>();
            Transform t = test.transform;

            GUIStyle green = new GUIStyle();
            GUIStyle red = new GUIStyle();

            green.normal.textColor = Color.green;
            red.normal.textColor = Color.red;

            FVector3 testValue = test.testValue;
            GUILayout.Label($"InverseTransformDirection\n{t.InverseTransformDirection((Vector3)testValue).ToString("F4")}\n{ft.InverseTransformDirection(testValue)}", ft.InverseTransformDirection(testValue).Equals(t.InverseTransformDirection((Vector3)testValue)) ? green : red);
            GUILayout.Label($"InverseTransformPoint\n{t.InverseTransformPoint((Vector3)testValue).ToString("F4")}\n{ft.InverseTransformPoint(testValue)}", ft.InverseTransformPoint(testValue).Equals(t.InverseTransformPoint((Vector3)testValue)) ? green : red);
            GUILayout.Label($"InverseTransformVector\n{t.InverseTransformVector((Vector3)testValue).ToString("F4")}\n{ft.InverseTransformVector(testValue)}", ft.InverseTransformVector(testValue).Equals(t.InverseTransformVector((Vector3)testValue)) ? green : red);

            GUILayout.Label($"TransformDirection\n{t.TransformDirection((Vector3)testValue).ToString("F4")}\n{ft.TransformDirection(testValue)}", ft.TransformDirection(testValue).Equals(t.TransformDirection((Vector3)testValue)) ? green : red);
            GUILayout.Label($"TransformPoint\n{t.TransformPoint((Vector3)testValue).ToString("F4")}\n{ft.TransformPoint(testValue)}", ft.TransformPoint(testValue).Equals(t.TransformPoint((Vector3)testValue)) ? green : red);
            GUILayout.Label($"TransformVector\n{t.TransformVector((Vector3)testValue).ToString("F4")}\n{ft.TransformVector(testValue)}", ft.TransformVector(testValue).Equals(t.TransformVector((Vector3)testValue)) ? green : red);

        }
    }

}

